{% extends "core/base_core.html" %}
{% block title %} - {{this_topic.name}}{% endblock %}
{% block content %}
    {% load markup %}
    <div id="content" class="content topic">
      <div class="container_16">
        <p class="bread-crumb"><a href="/topic">返回话题列表</a></p>
        
        <dl class="poll">
          <dt>状态</dt><dd class="poll-status">{{ this_topic.poll_status }}</dd>
          {% if this_topic.accepted and this_topic.in_event %}
            <dt>投票数</dt>
            <dd class="votes">
              <span class="number">{{ this_topic.total_votes }}</span><span class="unit">票</span>
            </dd>
          {% endif %}
          {% if this_topic.is_arranged and this_topic.accepted %}
            <dt>投票</dt>
            <dd class="vote-actions">
              {% if not is_voted %}
                <a class="vote" href="/topic/{{this_topic.id}}/vote">我想听</a>
              {% else %}
                <span class="voted">您投过票了</span>
              {% endif %}
            </dd>
          {% endif %}
          <a class="who-voted" href="/topic/{{this_topic.id}}/votes">看看都有谁投票了？</a>
        </dl>
        

        <h1 class="topic-name topic-name_{{this_topic.style_seed}}">{{ this_topic.name }}<span class="tail"></span></h1>
        
        {% if user == this_topic.author.user %}
            <p><a href="{% url edit_topic id=this_topic.id %}">编辑此话题</a></p>
        {% endif %}
        
        <p class="meta">
          <span class="topic-author">{{ this_topic.author.nickname }}</span>于“<span class="topic-created-at">{{ this_topic.created|date:'Y年m月d日' }}</span>”创建了这个话题{% if this_topic.accepted %}，计划在“<span class="topic-due-date">{{this_topic.in_event.begin_time|date:'Y年m月d日'}}</span>”的“<a href="/event/{{this_topic.in_event.id}}" class="topic-due-event">{{this_topic.in_event.name}}</a>”活动中演讲{% endif %}
        </p>
        
        <div>
          {{ this_topic.rendered_content|safe }}
        </div>

        {% if modified %}
          <p> 最近修改者：{{ this_topic.last_modified_by.nickname }} 于：{{ this_topic.last_modified|timesince }} 前</p>
        {% endif %}


          <h2 class="component-title">评论</h2>
          {% load comments %}
          {% get_comment_list for this_topic as comment_list %}
            <ul class="comments">
              {% for comment in comment_list %}
              <li id="c{{comment.id}}">
                  <span class="avatar"><img width=48 height=48 src="{{ comment.user.get_profile.avatar }}" alt="{{ comment.user.get_profile.display_name }}' Profile image" /></span>
                  <span class="username">{{ comment.user.get_profile.display_name }}</span>
                  <span class="timesince"> - {{ comment.submit_date|timesince }}前</span>
                  <span class="comment">{{ comment.comment }}</span>
                </li>
              {% endfor %}
            </ul>

          {% if user.is_authenticated %}
            {% get_comment_form for this_topic as form %}
            <form action="{% comment_form_target %}" method="POST">
              {% csrf_token %}
              {{ form.comment }}
              <div class="invisiable">
                {{ form.honeypot }}
              </div>
              {{ form.content_type }}
              {{ form.object_pk }}
              {{ form.timestamp }}
              {{ form.security_hash }}
              <input type="hidden" name="next" value="{% url topic this_topic.id %}" /><br />
              <input type="submit" value="发表评论" id="id_submit" />
            </form>
         {% else %}
          <p>如要发表评论，请先 <a href="{% url login %}">登录</a></p>
         {% endif %}


      </div>
    </div>
{% endblock %}
